/**
 * 路由配置文件
 * 定义应用的所有路由和对应组件
 */
import { createRouter, createWebHistory } from 'vue-router'

/**
 * 路由配置数组
 * 每个路由对象包含路径、名称、组件和可选的props配置
 */
const routes = [
  {
    path: '/',
    name: 'Home',
    component: () => import('../views/Home.vue') // 首页组件，使用懒加载方式导入
  },
  {
    path: '/events',
    name: 'EventList',
    component: () => import('../views/EventList.vue') // 事件列表页组件
  },
  {
    path: '/events/:id',
    name: 'EventDetail',
    component: () => import('../views/EventDetail.vue'), // 事件详情页组件
    props: true // 将路由参数作为props传递给组件
  },
  {
    path: '/events/:id/run',
    name: 'EventRun',
    component: () => import('../views/EventRun.vue'), // 事件运行页组件
    props: true
  },
  {
    path: '/categories',
    name: 'Categories',
    component: () => import('../views/CategoryList.vue') // 分类列表页组件
  },
  {
    path: '/logs',
    name: 'LogList',
    component: () => import('../views/LogList.vue') // 日志列表页组件
  },
  {
    path: '/logs/event/:eventId',
    name: 'EventLogList',
    component: () => import('../views/LogList.vue'), // 特定事件的日志列表页
    props: true
  },
  {
    path: '/variables',
    name: 'GlobalVariables',
    component: () => import('../views/GlobalVariables.vue') // 全局变量管理页面
  },
  {
    path: '/custom-nodes',
    name: 'CustomNodeList',
    component: () => import('../views/CustomNodeList.vue') // 自定义节点类型列表页
  },
  {
    path: '/custom-nodes/:id',
    name: 'CustomNodeDetail',
    component: () => import('../views/CustomNodeDetail.vue'), // 自定义节点类型详情/编辑页
    props: true
  },
  {
    path: '/custom-nodes/:id/versions',
    name: 'CustomNodeVersions',
    component: () => import('../views/CustomNodeVersions.vue'), // 自定义节点类型版本历史页
    props: true
  },
  {
    path: '/system-settings',
    name: 'SystemSettings',
    component: () => import('../views/SystemSettings.vue') // 系统设置页面
  }
]

/**
 * 创建路由实例
 * 使用HTML5历史模式，可以通过正常的URL访问而不是哈希URL
 */
const router = createRouter({
  history: createWebHistory(),
  routes
})

export default router 